# {{ ansible_managed }}
global
	log         {{ haproxy_config_log }}
	chroot      {{ haproxy_config_chroot }}
	pidfile     {{ haproxy_config_pidfile }}
	maxconn     {{ haproxy_config_maxconn }}
	user        {{ haproxy_config_user }}
	group       {{ haproxy_config_group }}
	daemon

	# turn on stats unix socket
	stats socket {{ haproxy_config_stats_socket }}

	# SSL tuning
	tune.ssl.default-dh-param {{ haproxy_config_ssl_default_dh_param }}
	ssl-default-bind-ciphers {{ haproxy_config_ssl_default_bind_ciphers }}
	ssl-default-bind-options {{ haproxy_config_ssl_default_bind_options }}
	ssl-default-server-ciphers {{ haproxy_config_ssl_default_server_ciphers }}
	ssl-default-server-options {{ haproxy_config_ssl_default_server_options }}

	# Base dir for certificates and CA files
	crt-base {{ haproxy_config_crt_base }}
	ca-base {{ haproxy_config_ca_base }}

{% if haproxy_peers is defined %}
# Configure peers for stick-table/session persistence replication
peers peers_global
{% for peer in haproxy_peers %}
	peer {{ peer.name }} {{ peer.ip }}:{{ peer.port }}
{% endfor %}
{% endif %}

{% for proxy in haproxy_proxies %}
{% set name = proxy.name|default("proxy_" ~ loop.index) %}

#
## Start of {{ name }} config
#

{% include proxy.template|default("custom") ~ ".j2" %}

#
## End of {{ name }} config
#
{% endfor %}
